<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <script src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
	
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
 <body class="layui-fluid" style="background:#fff;">


  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">费率设置</div>
          <div class="layui-card-body">
			  <from class="layui-form" action="" method="" wid100="" lay-filter="">
				  
					<div class="layui-form-item">
				  <label class="layui-form-label">种类设置</label>
							<div class="layui-col-sm6">
							  <select lay-filter="cnmd" id="select1" name="cdtypeid">
								<option value="" >请选择一个种类</option>
							  </select>
				  </div>
				  </div>
				  <div class="layui-form-item">
					<label class="layui-form-label">利率</label>
					<div class="layui-input-inline" style="width: 80px;">
					  <input type="number" id="rateNumber"  name="cache" lay-verify="number" value="" class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">单位为年利率</div>
				  </div>
				  
				  <div class="layui-form-item">
					<label class="layui-form-label">管理员密码</label>
					<div class="layui-input-inline">
					  <input type="password" name="send_nickname" value="123456" autocomplete="off" class="layui-input">
					</div>
				  </div>
				  <div class="layui-form-item">
					<div class="layui-input-block">
					  <button class="layui-btn" lay-submit="" lay-filter="set_system_send">确认保存</button>
					</div>
				  </div>
			  
            </from>
          </div>
        </div>
      </div>
    </div>
  </div>


  <script src="../../../layuiadmin/layui/layui.js"></script>
  <script>
  layui.config({
    base: '../../../layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'set']);
  layui.use(['form'], function() {
                    var form=layui.form;
  				    form.on('select(cnmd)', function(data){
  						    var val=data.value.split("&")[1];
  							changeRate(val);
  		  			 });
					 form.on('submit(set_system_send)', function(data){
					 	console.log(data.field);
						var json={
						    "cdtypeid":data.field.cdtypeid.split("&")[0],
						    "rate":data.field.cache,
						    "password":data.field.send_nickname
						}
						$.ajax({
							url: "http://www.longm.top:8080/lm/rate/edit",
							type: "post",
							dataType: 'json',
							headers:{
								'Content-Type':'application/json',
								'token':window.localStorage.getItem("token")
								},
							data:JSON.stringify(json),
							success: function (result) {
								if (result.code === 200) {
									var data=result.data;
									var select=document.querySelector("#select1");
									$("#select1").empty();
									for(i=0;i<data.length;i++)
									{
										var option=document.createElement("option");
										option.value=data[i].cdtypeid+"&"+data[i].rate;
										option.innerText=data[i].cdname;
										select.appendChild(option);
									}
									var form = layui.form;
									form.render('select');
									layer.msg(result["message"]);
								} else {
									layer.msg(result["message"]);
								}
							}
						});
					 	return false;
					 	})
   });
   layui.use(['form'], function() {
	   $.ajax({
	   	url: "http://www.longm.top:8080/lm/rate/Serach",
	   	type: "post",
	   	dataType: 'json',
	   	headers:{'Content-Type':'application/json'},
	   	data:{},
	   	success: function (result) {
	   		console.log(JSON.stringify(result));
	   		if (result.code === 200) {
	   				var data=result.data;
	   				var select=document.querySelector("#select1");
	   				for(i=0;i<data.length;i++)
	   				{
	   					var option=document.createElement("option");
	   					option.value=data[i].cdtypeid+"&"+data[i].rate;
	   					option.innerText=data[i].cdname;
	   					select.appendChild(option);
	   				}
					var form = layui.form;
	   				form.render('select');
	   		} else {
	   			layer.msg(result["message"]);
	   		}
	   	}
	   });
	   });
  </script>
  <script type="application/javascript">
	  
  	  function changeRate(rate)
  	  {
  	  	  document.querySelector("#rateNumber").value=rate;
  	  };
  </script>
<style id="LAY_layadmin_theme">.layui-side-menu,.layadmin-pagetabs .layui-tab-title li:after,.layadmin-pagetabs .layui-tab-title li.layui-this:after,.layui-layer-admin .layui-layer-title,.layadmin-side-shrink .layui-side-menu .layui-nav>.layui-nav-item>.layui-nav-child{background-color:#20222A !important;}.layui-nav-tree .layui-this,.layui-nav-tree .layui-this>a,.layui-nav-tree .layui-nav-child dd.layui-this,.layui-nav-tree .layui-nav-child dd.layui-this a{background-color:#009688 !important;}.layui-layout-admin .layui-logo{background-color:#20222A !important;}</style></body>
 </html>